package com.hzyl.famousreader.view.adapter;

import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.widget.TextView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.hzyl.famousreader.R;
import com.hzyl.famousreader.repository.persistence.entity.BookChapter;

import java.util.List;

/**
 * 阅读目录
 */
public class ReadCategoryAdapter extends BaseQuickAdapter<BookChapter, BaseViewHolder> {

  private Long curSelectedId;

  public ReadCategoryAdapter(@Nullable List<BookChapter> data, Long curSelectedId) {
    super(R.layout.item_catalog, data);
    this.curSelectedId = curSelectedId;
  }

  @Override
  protected void convert(BaseViewHolder helper, BookChapter item) {
    helper.setText(R.id.read_item_catalog, item.getTitle());
    TextView nextCatalog = helper.getView(R.id.read_item_catalog);
    if(curSelectedId != null && curSelectedId.equals(item.getId())) {
      nextCatalog.setTextColor(mContext.getResources().getColor(R.color.color_ec4a48));
    } else {
      nextCatalog.setTextColor(mContext.getResources().getColor(R.color.bg_black));
    }
  }

  public Long getCurSelectedId() {
    return curSelectedId;
  }

  public void setCurSelectedId(Long curSelectedId) {
    this.curSelectedId = curSelectedId;
  }
}
